const baseURL = import.meta.env.VITE_APP_BASE_URL;

/**
 * 树形数据
 * @param  templateExampleDataList 模板示例数据
 * */
export const getExamplesDataTree = (templateExampleDataList) => {
  return [
    {
      id: "quick-start",
      pid: null,
      name: "快速开始",
      icon: baseURL + "/icons/ksks.png",
      desc: "",
      count: 1,
      children: [
        {
          id: "create-3d-scene",
          pid: "quick-start",
          name: "创建三维场景",
          icon: "",
          desc: "",
          count: templateExampleDataList.filter(
            (x) => x.pid === "create-3d-scene"
          ).length,
          children: []
        }
      ]
    },
    {
      id: "3d-scene",
      pid: null,
      name: "三维场景",
      icon: baseURL + "/icons/ksks.png",
      desc: "",
      count: 2,
      children: [
        {
          id: "scene-style",
          pid: "3d-scene",
          name: "场景风格",
          icon: "",
          desc: "",
          count: templateExampleDataList.filter((x) => x.pid === "scene-style")
            .length,
          children: []
        },
        {
          id: "scene-interaction",
          pid: "3d-scene",
          name: "场景交互",
          icon: "",
          desc: "",
          count: templateExampleDataList.filter(
            (x) => x.pid === "scene-interaction"
          ).length,
          children: []
        }
      ]
    },
    {
      id: "3d-analysis",
      pid: null,
      name: "三维分析",
      icon: baseURL + "/icons/ksks.png",
      desc: "",
      count: 2,
      children: [
        {
          id: "basic-analysis",
          pid: "3d-analysis",
          name: "基础分析",
          icon: "",
          desc: "",
          count: templateExampleDataList.filter(
            (x) => x.pid === "basic-analysis"
          ).length,
          children: []
        },
        {
          id: "synthesis-analysis",
          pid: "3d-analysis",
          name: "综合分析",
          icon: "",
          desc: "",
          count: templateExampleDataList.filter(
            (x) => x.pid === "synthesis-analysis"
          ).length,
          children: []
        }
      ]
    },
    {
      id: "tile-image",
      pid: null,
      name: "瓦片底图",
      icon: baseURL + "/icons/ksks.png",
      desc: "",
      count: 2,
      children: [
        {
          id: "load-online-map",
          pid: "tile-image",
          name: "在线地图加载", 
          icon: "",
          desc: "",
          count: templateExampleDataList.filter(
            (x) => x.pid === "load-online-map"
          ).length,
          children: []
        },
        {
          id: "load-offline-map",
          pid: "tile-image",
          name: "离线地图加载",
          icon: "",
          desc: "",
          count: templateExampleDataList.filter(
            (x) => x.pid === "load-offline-map"
          ).length,
          children: []
        }
      ]
    }
  ];
};
